/*
 * Copyright 2003 Program of Computer Graphics, Cornell University
 *     580 Rhodes Hall
 *     Cornell University
 *     Ithaca NY 14853
 * Web: http://www.graphics.cornell.edu/
 * 
 * Not for commercial use. Do not redistribute without permission.
 */

#ifndef _H_POOLALLOCATOR
#define _H_POOLALLOCATOR

//allocate in 128K chunks
#define POOL_SEGMENT_SIZE (1<<17)


class PoolAllocator {
  int defaultAlignment;
  int segmentSize;
  int numSegments;
  int totalBytes;
  class PoolAllocationSegment *curSegment;

  void mallocNewSegment(int size);
public:
  PoolAllocator(int defaultSegmentSize, int alignment);
  ~PoolAllocator();

  void *allocate(int size) { return allocate(size,defaultAlignment); }
  void *allocate(int size, int alignment);
  void deallocateAll();

  int getTotalSize() { return totalBytes; }
};


#endif //_H_POOLALLOCATOR

